#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/12/27 20:21
# @Author  : Sun
# @File    : modify_family_note.py
# @Software: PyCharm
import json

import requests

from common.read_yaml import ReadYaml
from common.write_log import WriteLog


class CheckTaskProgress:
    _URL = ReadYaml().read_yaml().get('domain') + "/task/checkTaskProgress"
    # classId和areaId值一样
    _DATA = {
        "classId": None,
        "maxFsmId": 0,
        "areaId": None
    }
    _HEADERS = {
        'platform': 'RN',
        'Authorization': None,
        'Content-Type': 'application/json;charset=utf-8'
    }

    def check_task_progress(self, JJUid, classId):
        # self._HEADERS['Authorization'] = GetFamilyToken(
        # ).get_token(JJUid=JJUid)
        self._DATA['classId'] = classId
        self._DATA['areaId'] = classId
        self._HEADERS['authorization'] = ReadYaml().read_yaml(file_path="./config/family_token.yaml").get(JJUid)
        r = requests.request(
            method='POST',
            url=self._URL,
            headers=self._HEADERS,
            data=json.dumps(self._DATA))
        result = json.dumps(r.json(), ensure_ascii=False, indent=4)
        WriteLog().write_log().info(result)
        return result


if __name__ == '__main__':
    CheckTaskProgress().check_task_progress(JJUid=106146203)
